//
//  DownSideView.m
//  OpenYourEyes
//
//  Created by zhanglei on 15/8/11.
//  Copyright (c) 2015年 zhanglei. All rights reserved.
//

#import "DownSideView.h"

@implementation DownSideView


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        CGFloat ten = SCREEN_WIDTH / 48;
        _firstView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2)];
        _firstView.backgroundColor = [UIColor clearColor];
        //背景图片
        UIImageView *blackImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2)];
        blackImageView.backgroundColor = [UIColor blackColor];
        [self addSubview:blackImageView];
        
        _downSideImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2)];
//        _downSideImageView.image = [UIImage imageNamed:@"1.jpg"];
        _downSideImageView.alpha = 0.5;
        [self addSubview:_downSideImageView];
        
        //标题
        _titleLabel = [[ZTypewriteEffectLabel alloc]initWithFrame:CGRectMake(ten, ten, SCREEN_WIDTH - 2 * ten, 3 * ten)];
        _titleLabel.backgroundColor = [UIColor clearColor];
//        _titleLabel.text = @"";
        _titleLabel.font = [UIFont systemFontOfSize:3 * ten weight:2];
        _titleLabel.textColor = [UIColor clearColor];
        _titleLabel.typewriteTimeInterval = 0.05;
        _titleLabel.typewriteEffectColor = [UIColor colorWithWhite:0.900 alpha:1.000];
        [_firstView addSubview:_titleLabel];
        
        //白线
        UIImageView *whiteLine = [[UIImageView alloc]initWithFrame:CGRectMake(ten, 5.5 * ten, 25 * ten, 0.5)];
        whiteLine.backgroundColor = [UIColor colorWithWhite:0.900 alpha:1.000];
        [_firstView addSubview:whiteLine];
        
        //标签/类别
        _categoryLabel = [[ZTypewriteEffectLabel alloc]initWithFrame:CGRectMake(ten, 6.5 * ten, 15 * ten, 3 * ten)];
        _categoryLabel.backgroundColor = [UIColor clearColor];
        _categoryLabel.font = [UIFont systemFontOfSize:1.8 * ten weight:1];
        _categoryLabel.typewriteTimeInterval = 0.05;
//        _categoryLabel.text = @"测试";
        _categoryLabel.textColor = [UIColor clearColor];
        _categoryLabel.typewriteEffectColor = [UIColor colorWithWhite:0.900 alpha:1.000];
        [_firstView addSubview: _categoryLabel];
        
        //详情
        _descriptionLabel = [[ZTypewriteEffectLabel alloc]initWithFrame:CGRectMake(ten , 7 * ten, SCREEN_WIDTH - 2 * ten ,  15 * ten)];
        _descriptionLabel.backgroundColor = [UIColor clearColor];
        _descriptionLabel.numberOfLines = 4;
        _descriptionLabel.font = [UIFont systemFontOfSize:1.8 * ten weight:1];
        _descriptionLabel.textColor = [UIColor clearColor];
        _descriptionLabel.typewriteTimeInterval = 0.01;
        _descriptionLabel.typewriteEffectColor = [UIColor colorWithWhite:0.900 alpha:1.000];
        [_firstView addSubview:_descriptionLabel];
        


//        _collectionCount = [[BaseButtonVIew alloc]initWithFrame:CGRectMake(0, 22 * ten, 20 * ten, 5 * ten) name:@"等一下" Image:[UIImage imageNamed:@"iconfont-weishoucang"]];
//        _playCount = [[BaseButtonVIew alloc]initWithFrame:CGRectMake(21 * ten, 22 * ten , 20 * ten, 5 * ten) name:@"先写个数" Image:[UIImage imageNamed:@"iconfont-kongxinaixin-2"]];
//
//        [_firstView addSubview:_collectionCount];
//        [_firstView addSubview:_playCount];
        
        [_downSideImageView addSubview:_footView];
        [self addSubview:_firstView];
        
    }
    return self;
}

-(void)startOutPut
{
    [_descriptionLabel removeAllSetting];
    [_categoryLabel removeAllSetting];
    [_titleLabel removeAllSetting];
    
    [_descriptionLabel startTypewrite];
    [_categoryLabel startTypewrite];
    [_titleLabel startTypewrite];
}

- (void)setModel:(DailyModel *)model
{
    _model = model;
    [_downSideImageView sd_setImageWithURL:[NSURL URLWithString:_model.coverBlurred]];
    _titleLabel.text = _model.title;
    NSInteger time = model.duration;
    NSString *timeStr = [NSString stringWithFormat:@"%d'%d\"", time / 60 , time % 60];
    NSString *text = [NSString stringWithFormat:@"#%@  /  %@",model.category,timeStr];
    _categoryLabel.text = text;
    _descriptionLabel.text = _model.Description;
    
    NSString *collection = [_model.consumption[@"shareCount"] stringValue];
    NSString *collectionNew = [NSString stringWithFormat:@"收藏:%@",collection];
    _collectionCount.iconLabel.text = [NSString stringWithFormat:@"%@",collectionNew];
    
}

@end
